package com.panda.game.xls.screen;

import com.panda.game.xls.action.OpenFileAction;
import com.panda.game.xls.action.OutputInforAction;
import com.panda.game.xls.component.MyJButton;
import com.panda.game.xls.component.MyJComboBox;
import com.panda.game.xls.component.MyJLabel;
import com.panda.game.xls.component.MyJTextField;
import com.panda.game.xls.config.Person;
import com.panda.game.xls.config.PersonConfig;
import com.panda.game.xls.config.SheetTypeData;
import com.panda.game.xls.config.SheetTypeDataConfig;

import javax.swing.*;
import java.awt.*;
import java.util.List;

public class TabPage1 extends TabPageFather implements TabInterface {

    private static MyJLabel row1Label1;
    private static MyJComboBox row1Cmb1;

    private static MyJLabel row2Label1;
    private static MyJComboBox row2Cmb1;

    private static MyJButton row3Btn1;

    private static MyJTextField jtf;

    private static MyJButton fileBtn;


    public TabPage1() {
        super();
        setLayout(new GridLayout(4, 2));
        setDefaultSeting();
        setTabContent();
    }

    @Override
    public void setTabContent() {
        //row1
        row1Label1 = new MyJLabel("充值类型：");
        add(row1Label1);

        row1Cmb1 = new MyJComboBox();
        reflashSheetTypeData();
        add(row1Cmb1);
        //row1

        //row2
        row2Label1 = new MyJLabel("操作人：");
        add(row2Label1);

        row2Cmb1 = new MyJComboBox();
        reflashPerson();
        add(row2Cmb1);
        //row2

        //row3
        row3Btn1 = new MyJButton();
        Action action1 = new OutputInforAction();
        row3Btn1.setAction(action1);
        row3Btn1.setEnabled(true);
        row3Btn1.setText("输出");
        add(row3Btn1);

        jtf = new MyJTextField(25);
        add(jtf);

        fileBtn = new MyJButton();
        fileBtn.setText("浏览");
        fileBtn.addActionListener(new OpenFileAction(jtf));
        add(fileBtn);
        //row3
    }

    public static void reflashSheetTypeData() {
        row1Cmb1.removeAllItems();
        row1Cmb1.addItem("--请选择--");
        List<SheetTypeData> sheetTypeDataList = SheetTypeDataConfig.getSheetTypeDataList();
        for (SheetTypeData sheetTypeData : sheetTypeDataList) {
            row1Cmb1.addItem(sheetTypeData.getName());
        }
    }

    public static void reflashPerson() {
        row2Cmb1.removeAllItems();
        row2Cmb1.addItem("--请选择--");
        List<Person> personlist = PersonConfig.getPersonList();
        for (Person person : personlist) {
            row2Cmb1.addItem(person.getName());
        }
    }

    public static MyJLabel getRow1Label1() {
        return row1Label1;
    }

    public static MyJComboBox getRow1Cmb1() {
        return row1Cmb1;
    }

    public static MyJLabel getRow2Label1() {
        return row2Label1;
    }

    public static MyJComboBox getRow2Cmb1() {
        return row2Cmb1;
    }

    public static MyJButton getRow3Btn1() {
        return row3Btn1;
    }

}
